package com.tanhua.server.controller;

import com.tanhua.domain.vo.PageResult;
import com.tanhua.domain.vo.RecommendUserQueryParam;
import com.tanhua.domain.vo.RecommendUserVo;
import com.tanhua.server.service.IMService;
import com.tanhua.server.service.RecommendUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * 交友----消费者模块
 */
@RestController
@RequestMapping("/tanhua")
public class RecommendUserController {
    //注入RecommendUserService
    @Autowired
    private RecommendUserService recommendUserService;

    @Autowired
    private IMService imService;

    /**
     * 今日佳人
     * @return
     */
    @GetMapping("/todayBest")
    public ResponseEntity todayBest(){

        //调用 RecommendUserService 业务处理
        RecommendUserVo todayBest =  recommendUserService.todayBest();

        return ResponseEntity.ok(todayBest);
    }

    /**
     * 推荐朋友
     */
    @GetMapping("/recommendation")
    public ResponseEntity recommendList(RecommendUserQueryParam queryParam){

        PageResult<RecommendUserQueryParam> pageResult =recommendUserService.recommendList(queryParam);

        return ResponseEntity.ok(pageResult);

    }

    /**
     * 佳人信息
     * @param userId
     * @return
     */
    @GetMapping("/{userId}/personalInfo")
    public ResponseEntity getPersonalInfo(@PathVariable Long userId){
        RecommendUserVo   vo = recommendUserService.getPersonalInfo(userId);

        return ResponseEntity.ok(vo);
    }

    /**
     * 查看佳人陌生人问题
     * @param userId
     * @return
     */
    @GetMapping("/strangerQuestions")
    public ResponseEntity strangerQuestions(Long userId){
        String question = recommendUserService.strangerQuestions(userId);
        return ResponseEntity.ok(question);
    }



    /**
     * 回复佳人陌生人问题
     * @param paramMap
     * @return
     */
    @PostMapping("/strangerQuestions")
    public ResponseEntity replyStrangerQuestions(@RequestBody Map<String,Object> paramMap){
        recommendUserService.replyStrangerQuestions(paramMap);
        return ResponseEntity.ok(null);
    }
}
